import { get, post, remove, put } from '@/server/request'
import { baseApi, RequestCode } from '@/server/base'

export const Team = {
  /**
   * 查询数据
   * @param params 
   * @returns 
   */
  list(params?: any) {
    return get(`${baseApi}/team/list`, params);
  },
  // /**
  //  * 查询数据
  //  * @param params 
  //  * @returns 
  //  */
  // listAll(params?: { name: string, current: number, size: number }) {
  //   return get(`${baseApi}/tag/listAll`, params);
  // },
  /**
   * 删除一条数据
   * @returns : Promise<RequestCode>
   */
  removeById(params: { id: string | number }) {
    return remove(`${baseApi}/team/delete/${params.id}`);
  },
  // /**
  //  * 根据ID获取一条数据
  //  * @param params 
  //  * @returns 
  //  */
  // getTagDetailById(params: { id: string | number }) {
  //   return get(`${baseApi}/tag/get`, params);
  // },
  /**
   * 添加一条数据
   * @param params 
   */
  addTeamInfo(params: TeamInfo) {
    return post(`${baseApi}/team/save`, params);
  },
  /**
   * 修改一条数据
   * @param params 
   * @returns 
   */
  modifyTeamInfo(params: TeamInfo) {
    return put(`${baseApi}/team/update/${params.id}`, params);
  },

  /**
   * 获取团队下的所有成员
   */
  getPersonById(teamId: string | number) {
    return get(`${baseApi}/team/getPersonByTeam/${teamId}`);
  },

  /**
   * 添加成员
   * @param params 
   * @returns 
   */
  appendTeamPersonInfo(params: {
    email: string,
    jobNumber: string,
    mobile: string,
    name: string,
    roleId: number
    teamId: number
    userId?: number
    username: string,
  }) {
    return post(`${baseApi}/team/saveMember`, params);
  },
  /**
   * 添加成员
   * @param params 
   * @returns 
   */
  modifyTeamPersonInfo(params: {
    email: string,
    jobNumber: string,
    mobile: string,
    name: string,
    roleId: number
    teamId: number
    userId?: number
    username: string,
  }) {
    return put(`${baseApi}/team/modifyTheMember`, params);
  },

  /**
   * 移除团队成员
   * @param params 
   * @returns 
   */
  removePersonById(params: { id: string | number, teamId: string | number }) {
    return remove(`${baseApi}/team/removeMember/${params.teamId}/${params.id}`);
  },


  /**
   * 获取非本团队的用户
   * @param params 
   * @returns 
   */
  otherUserList(params: { current: number, size: number, teamId: string | number }) {
    const { teamId, current, size, ..._params } = params;
    return get(`${baseApi}/team/query/${teamId}/${current}/${size}`, _params);
  },





}

export type TeamInfo = {
  id?: string | number,
  createTime?: string,
  updateTime?: string,
  item: string,//	路径	
  meta: string,//	元数据	
  name: string,//	菜单名称	
  parentId: number,//	父目录id，无父目录则为0	
  type: number
}

